const replaceEmpty = (string)=>{
  return string.replace(/\s+/g,'20%')
}

const replaceEmpty2 = (string)=>{
  return string.replace(/\s/g,'20%')
}

const newStr = replaceEmpty('i love    ddd ddjejjen c  eee');
const newStr2 = replaceEmpty2('i love    ddd ddjejjen c  eee');

console.log(newStr);
console.log(newStr2);